package com.thread;

/**
 * @author :admin
 * @description: 测试线程停止(待完整)
 * @create date: 2019/4/3 10:50
 */
public class ThreadDemoStop implements Runnable {

    public static void main(String[] args) throws InterruptedException {
            Thread thread=new Thread(new ThreadDemoStop(),"ThreadA1");
            thread.start();
            Thread.sleep(1000);
            thread.interrupt();
    }


    @Override
    public void run() {
        Thread currentThread = Thread.currentThread();
        while (true){
            if (currentThread.isInterrupted()){
                System.out.println("current thread interrupt :" + currentThread.interrupted());
                System.out.println("current thread isInterrupted :" + currentThread.interrupted());
                break;
            }
        }
        System.out.println("not stop thread");


    }
}
